package com.hgyc.mom.wms.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hgyc.mom.common.vo.Result;
import com.hgyc.mom.core.mybatis.QueryWrapperUtil;
import com.hgyc.mom.wms.entity.WmsPurchaseReceiptDetail;
import com.hgyc.mom.wms.service.WmsPurchaseReceiptDetailService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 物料入库单行Controller
 *
 * @author fwj
 * @since 2025-07-08
 */
@Tag(name = "物料入库单行控制器", description = "物料入库单行控制器")
@RestController
@RequestMapping("/wms/purchase/receipt/detail")
public class WmsPurchaseReceiptDetailController {
    @Autowired
    private WmsPurchaseReceiptDetailService wmsPurchaseReceiptDetailService;


    @Operation(summary = "查询物料入库单行树列表", description = "查询物料入库单行树列表")
    @PostMapping("/list")
    public Result<List<WmsPurchaseReceiptDetail>> pageList(@Parameter(description = "查询参数") @RequestBody WmsPurchaseReceiptDetail wmsPurchaseReceiptDetail) {
        QueryWrapper<WmsPurchaseReceiptDetail> wrapper = QueryWrapperUtil.build(wmsPurchaseReceiptDetail);
        List<WmsPurchaseReceiptDetail> list = wmsPurchaseReceiptDetailService.list(wrapper);
        return Result.success(list);
    }

    @Operation(summary = "获取物料入库单行详细信息", description = "获取物料入库单行详细信息")
    @GetMapping(value = "/{lineId}")
    public Result getInfo(@Parameter(description = "物料入库单行ID") @PathVariable("lineId") Long lineId) {
        return Result.success(wmsPurchaseReceiptDetailService.getById(lineId));
    }

}